package game.objects;
import physics.Body;
import physics.tools.Initializer;
import sound.main.Sound;
import tools.Floatmath;
import tools.Point;
import game.Game;
import game.engine.GSync;
import graphics.objects.GPointLight;
import graphics.objects.GRect;
import graphics.system.Color;
public class GOBox extends GameObject {
	private float a;
	private float b;
	private float mass;
	private Sound sound;
	private GPointLight l;
	public GOBox(Game g, Point pos, float a, float b, float mass, float angle) {
		super(g, pos, angle);
		this.a = a;
		this.b = b;
		sound = new Sound("song.ogg");
		sound.setLoop(true);
		sound.setVolume(3);
		this.mass = mass;
	}
	@Override
	public void initialize(Point pos, float angle) {
		// addBodyWithGraphics(Initializer.getRectangle(pos, a * 2, b * 2, mass
		// , angle), color);
		Body b = Initializer.getRectangle(pos, this.a * 2, this.b * 2, mass, angle);
		addBody(b);
		GRect gb = new GRect(pos, this.a * 2, this.b * 2, angle, "powercell_full");
		gb.setGlow(false);
		gb.setShadow(false);
		l = new GPointLight(pos, 100, new Color(0,1,0,1));
		addGraphicsObject(l,new GSync(b));
		
		
		gb.glowColor = new Color(0, 1, 0, 1);
		// gb.setTexResize(new Point(1.07f,1.07f));
		addGraphicsObject(gb, new GSync(b));
		sound.play();
	}
	@Override
	public void handle() {
		sound.setPos(getBody(0).pos);
		l.setRadius(Math.abs(Floatmath.sin(game.time))*100);
	}
}
